import {
 	baseUrl
 } from "@/common/config.js"

 export function fullUrl(urlPath) {
 	if (typeof urlPath != "string") return undefined;
 	//如果包含http字符串，直接返回
 	if (urlPath.includes("http")) {
 		return urlPath;
 	}

 	if (!urlPath) return urlPath;

 	//加上BaseAPI生成图片完整Url
 	return `${baseUrl}${urlPath}`;
 }

 export function isMobile() {
 	//这里应有条件编译
 	return /Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent);
 }
 
 //---------------------------------------------------
 // 日期格式化  
 // 格式 YYYY/yyyy/YY/yy 表示年份  
 // MM/M 月份  
 // W/w 星期  
 // dd/DD/d/D 日期  
 // hh/HH/h/H 时间  
 // mm/m 分钟  
 // ss/SS/s/S 秒  
 //--
 export function dateFormat(date, formatStr) {
 	let isDate = date instanceof Date;
 	if(isDate == false) return "";
 	
 	let str = formatStr;
 	let Week = ['日', '一', '二', '三', '四', '五', '六'];
 
 	str = str.replace(/yyyy|YYYY/, date.getFullYear());
 	str = str.replace(/yy|YY/, (date.getYear() % 100) > 9 ? (date.getYear() % 100).toString() : '0' + (date.getYear() %
 		100));
 
 	str = str.replace(/MM/, date.getMonth() > 9 ? date.getMonth().toString() : '0' + date.getMonth());
 	str = str.replace(/M/g, date.getMonth());
 
 	str = str.replace(/w|W/g, Week[date.getDay()]);
 
 	str = str.replace(/dd|DD/, date.getDate() > 9 ? date.getDate().toString() : '0' + date.getDate());
 	str = str.replace(/d|D/g, date.getDate());
 
 	str = str.replace(/hh|HH/, date.getHours() > 9 ? date.getHours().toString() : '0' + date.getHours());
 	str = str.replace(/h|H/g, date.getHours());
 	str = str.replace(/mm/, date.getMinutes() > 9 ? date.getMinutes().toString() : '0' + date.getMinutes());
 	str = str.replace(/m/g, date.getMinutes());
 
 	str = str.replace(/ss|SS/, date.getSeconds() > 9 ? date.getSeconds().toString() : '0' + date.getSeconds());
 	str = str.replace(/s|S/g, date.getSeconds());
 
 	return str;
 }
 
